package aufgabe9;

public class Counter
{
  private int count;
  private int obergrenze;
  
  public Counter(int obergrenze)
  {
    count = 0;
    this.obergrenze = obergrenze;
  }
  
  public void plus() throws CounterOutOfRangeException
  {
    count++;
    if(count > obergrenze)
      throw new CounterOutOfRangeException();
  }
  public void minus() throws CounterOutOfRangeException
  {
    count--;
    if(count < 0)
      throw new CounterOutOfRangeException();
  }
  public String toString()
  {
    return count+"";
  }
}
